﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace PMS.XCMG.Util
{
    public interface IBaseRepository<T>
        where T : class, new()
    {
        IQueryable<E> GetQueryable<E>(bool noTracking = false) where E : class;
        IQueryable<T> GetQueryable(bool noTracking = false);

        Task<List<T>> GetListAsync(List<object> ids, bool noTracking = false);
        Task<List<T>> GetListAsync(Expression<Func<T, bool>> predicate, bool noTracking = false);
        Task<List<T>> GetListAsync(IQueryable<T> queryable);
        Task<List<T>> GetPageListAsync(IQueryable<T> queryable, PageInput query);
        Task<PageResult<T>> GetPageResultAsync(IQueryable<T> queryable, PageInput query);
        Task<List<T>> GetAll(bool noTracking = false);

        ValueTask<T> GetAsync(params object[] keyValues);
        Task<T> GetAsync(Expression<Func<T, bool>> predicate, bool noTracking = false);
        Task<T> GetAsync(IQueryable<T> queryable);
        Task<T> GetByCodeAsync(string code, bool noTracking = false);

        Task<int> AddAsync(T entity);
        Task<int> AddAsync(List<T> entitys);

        Task<int> DeleteAsync(T entity);
        Task<int> DeleteAsync(List<T> entitys);
        Task<int> DeleteAsync(params object[] keyValues);
        Task<int> DeleteAsync(List<object> ids);

        Task<int> UpdateAsync(T entity);
        Task<int> UpdateAsync(List<T> entitys);


        Task<int> SaveChangesAsync();
    }
}
